<?php
namespace app\baseinfo\model;
use \think\Model;

class Product extends \app\common\model\Base{
	protected $table='xl_product';
	// protected $visible=['name','description'];

	// protected $createTime='product_date';

	// protected $autoWriteTimestamp='datetime';

  protected $append=['submitter','company','is_deleted'];
	protected $insert=['submitter_id','submitter_time'];
	protected $_RejectCreate = ['submitter_time','submitter'];
  protected $_RejectUpdate = ['submitter_time','submitter'];
	use \app\common\model\BaseSubmitter;

	public function batches() {
		return $this->hasMany("scodetrace/Batch");
	}

	public function company() {
		return $this->belongsTo('Company');
	}

	public function getIsDeletedAttr($value,$data) {
		if (isset($data['deleted']) && $data['deleted']) {
			return '已删除';
		} else {
			return '';
		}
	}

	protected function _doing_delDataById($delIds){
		if (db($this->table)->where('id', 'in', $delIds)->update(['deleted'=>1])){
			return true;
		}
		return false;
	}
}

?>